
//公共请求前缀
import axios from "axios";
import {ElMessage} from "element-plus";

const baseURL = '/api'

//自定义axios请求
const myAxios = axios.create({baseURL})

myAxios.interceptors.response.use(
    result => {
    //判断业务状态码
    if(result.data.code===0 || result.data.code===2){
        return result.data;
    }

    //操作失败
    //alert(result.data.msg?result.data.msg:'服务异常')
    ElMessage.error(result.data.msg?result.data.msg:'服务异常')
    //异步操作的状态转换为失败
    return Promise.reject(result.data)

})

export default myAxios